package br.unesp.rc.rafaelt.resources;

/**
 * http://dafionsoftware.blogspot.com.br/2011/05/how-to-call-jersey-restful-service-from.html
 */

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.unesp.rc.rafaelt.business.services.SubjectServices;
import br.unesp.rc.rafaelt.business.to.SubjectListTO;
import br.unesp.rc.rafaelt.model.bean.Subject;

@Component
@Path("/subject")
public class SubjectResource {

	@Autowired
	SubjectServices subjectServices;

	@GET
	@Path("{id:[0-9]+}")
	@Produces({ MediaType.APPLICATION_JSON })
	public Response findById(@PathParam("id") final Long id) {
		Subject subject = subjectServices.findById(id);
		
		return Response.ok(subject).build();
	}
	
	@GET
	@Produces({ MediaType.APPLICATION_JSON })
	public Response findAll() {
		SubjectListTO subjectList = subjectServices.findAll();
		
		return Response.ok(subjectList).build();
	}	

}